package cn.wolfcode.shop.service.impl;

import cn.wolfcode.shop.domain.PropertyValue;
import cn.wolfcode.shop.mapper.PropertyValueMapper;
import cn.wolfcode.shop.service.IPropertyValueService;
import com.alibaba.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class PropertyValueServiceImpl implements IPropertyValueService {

    @Autowired
    private PropertyValueMapper propertyValueMapper;

    @Override
    public List<PropertyValue> queryByPropertyId(Long propertyId) {
        return propertyValueMapper.selectByPropertyId(propertyId);
    }

    @Override
    public void batchSaveOrUpdate(List<PropertyValue> propertyValueList) {
        for (PropertyValue propertyValue : propertyValueList) {
            if (propertyValue.getId() == null) {

                propertyValueMapper.insert(propertyValue);
            } else {
                propertyValueMapper.updateByPrimaryKey(propertyValue);
            }
        }
    }


    @Override
    public void deleteByPVId(Long propertyValueId) {

        propertyValueMapper.deleteByPrimaryKey(propertyValueId);
    }
}
